set nocompatible " be iMproved, required
filetype off " required
set ts=4
set expandtab
%retab!
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
filetype plugin indent on " required
Bundle 'wakatime/vim-wakatime'
Bundle 'a.vim'
Bundle 'c.vim'
Bundle 'grep.vim'
Bundle 'taglist.vim'
Bundle 'fholgado/minibufexpl.vim'
Bundle 'fatih/vim-go'
Bundle 'skywind3000/asyncrun.vim'
Bundle 'rhysd/vim-clang-format'
set term=xterm      "退出vim时清屏
syntax enable
syntax on
set nu
set shortmess=atI
set go=
set ruler
set showcmd         "输入的命令显示出来，看的清楚些
set cursorline      "突出显示当前行
hi cursorline cterm=none ctermbg=Black ctermfg=none
"set cursorcolumn
"autocmd InsertEnter * highlight CursorLine guibg=#000050 guifg=fg
"autocmd InsertLeave * highlight CursorLine guibg=#004000 guifg=fg
"hi cursor ctermfg=white ctermbg=red cterm=bold guifg=white guibg=yellow gui=bold
"hi CursorColumn ctermfg=White ctermbg=Yellow cterm=bold guifg=white guibg=blue gui=bold
set confirm
set tabstop=4
set shiftwidth=4
set expandtab
set nobackup
set noswapfile
set ignorecase
set hlsearch
set incsearch
"编码设置
set enc=utf-8
set fencs=utf-8,gb18030,gbk,gb2312,cp936
"语言设置
set langmenu=zh_CN.UTF-8
set helplang=cn
set laststatus=2
set cmdheight=2
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\%{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
"filetype on
filetype plugin on
set completeopt=longest,menu
set autoread
set noeb
"去空行
"nnoremap <F2> :g/^\s*$/d<CR>
"map <F3> :tabnew .<CR>
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "! ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "! ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'sh'
:!./%
endif
endfunc
"C,C++的调试
map <F8> :call Rungdb()<CR>
func! Rungdb()
exec "w"
exec "!g++ % -g -o %<"
exec "!gdb ./%<"
endfunc

nnoremap <F2> :call Am()<CR>
func! Am()
    exec "w"
    exec "AsyncRun make"
endfunc
nnoremap <F3> :call Amc()<CR>
func! Amc()
    exec "AsyncRun make clean && make"
endfunc

set laststatus=2
set t_Co=256
let g:Powerline_symbols = 'unicode'
set encoding=utf8
let g:go_disable_autoinstall = 0
" let g:go_version_warning = 0
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1

func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: RogerLuo")
call append(line(".")+2, "\# mail: 13369189710@163.com")
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\#########################################################################")
call append(line(".")+5, "\#!/bin/bash")
call append(line(".")+6, "") 
elseif &filetype == 'cpp' || &filetype == 'c'
call setline(1,"\/***********************************************************************")
call append(line("."), "\* File Name: ".expand("%"))
call append(line(".")+1, "\* Author: RogerLuo")
call append(line(".")+2, "\* mail: 13369189710@163.com")
call append(line(".")+3, "\* Created Time: ".strftime("%c"))
call append(line(".")+4, "\***********************************************************************/")
call append(line(".")+5, "\#include \"\"")
call append(line(".")+6, "") 
endif
"新建文件后，自动定位到文件末尾
 autocmd BufNewFile * normal G
endfunc

"新建.c,.h,.sh,.java文件，自动插入文件头
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"
""定义函数SetTitle，自动插入文件头


"*********ctaglist******
"let Tlist_Auto_Open=1 
let Tlist_Sort_Type = "name" " 按照名称排序 
let Tlist_Use_Right_Window = 1 " 在右侧显示窗口 
let Tlist_Compart_Format = 1 " 压缩方式 
let Tlist_Exist_OnlyWindow = 1 " 如果只有一个buffer，kill窗口也kill掉buffer 
let Tlist_File_Fold_Auto_Close = 0 " 不要关闭其他文件的tags 
let Tlist_Enable_Fold_Column = 0 " 不要显示折叠树 
"禁止生成临时文件
set nobackup
set noswapfile
" 使回格键（backspace）正常处理indent, eol, start等
set backspace=2
" " 允许backspace和光标键跨越行边界
set whichwrap+=<,>,h,l
" 通过使用: commands命令，告诉我们文件的哪一行被改变过
set report=0
" " 在被分割的窗口间显示空白，便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" " 高亮显示匹配的括号
set showmatch
" " 匹配括号高亮的时间（单位是十分之一秒）
set matchtime=1
" " 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
" " 为C程序提供自动缩进
set smartindent

"let g:DoxygenToolkit_briefTag_funcName = "yes"
"let g:DoxygenToolkit_commentType = "C++"
"let g:DoxygenToolkit_briefTag_pre = "\\brief "
"let g:DoxygenToolkit_templateParamTag_pre = "\\tparam "
"let g:DoxygenToolkit_paramTag_pre = "\\param "
"let g:DoxygenToolkit_returnTag = "\\return "
"let g:DoxygenToolkit_fileTag = "\\file "
"let g:DoxygenToolkit_dateTag = "\\date "
"let g:DoxygenToolkit_authorTag = "\\author "
"let g:DoxygenToolkit_versionTag = "\\version "
"let g:DoxygenToolkit_blockTag = "\\luojie "
"let g:DoxygenToolkit_classTag = "\\class "
"let g:DoxygenToolkit_authorName = "Qian Gu, guqian110@gmail.com"
"let g:doxygen_enhanced_color = 1

"nnoremap <silent> <F3> :Grep<CR>
" vim-powerline
hi MBEVisibleActiveNormal cterm=underline ctermfg=81
hi Search term=standout ctermfg=0 ctermbg=3

let g:clang_format#style_options = {
            \ "AccessModifierOffset" : -4,
            \ "AllowShortIfStatementsOnASingleLine" : "true",
            \ "AlwaysBreakTemplateDeclarations" : "true",
            \ "Standard" : "C++11"}

" map to <Leader>cf in C++ code
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>cf :ClangFormat<CR>
" " if you install vim-operator-user
autocmd FileType c,cpp,objc map <buffer><Leader>x <Plug>(operator-clang-format)
" " Toggle auto formatting:
nmap <Leader>C :ClangFormatAutoToggle<CR>

"autocmd FileType c ClangFormatAutoEnable
"autocmd FileType cpp ClangFormatAutoEnable

if !has("gui_running")  
    set t_Co=256  
endif  
if &diff  
    colors peaksea  
endif  
